home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-171.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  44.5 KB  |  1,204 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Fri, 02 Oct 92       Volume 1 : Issue 171
  2.  
  3. Today's Topics:
  4.  
  5.     Beyond List Manager
  6.     SUMMARY:  Making an icon (was "ARGH! No icon!")
  7.     Think C Debugger & Class dynamic typing... summary
  8.     List of bizarre, useful keyboard combinations, version 1.1
  9.     UNofficial description of 2 Layer Manager calls
  10.     How to query current pixel depth?
  11.     Think C arrays
  12.     MoveHHi invalidates heap?
  13.     Dragging Lines
  14.     Can copybits _add_ the source pixmap index to the dest index?
  15.  
  16.  
  17.  
  18. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  19.  
  20. The digest is a collection of article threads from the internet newsgroup
  21. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  22. regularly and want an archive of the discussions.  If you don't know what a
  23. newsgroup is, you probably don't have access to it.  Ask your systems
  24. administrator(s) for details.  (This means you can't post questions to the
  25. digest.)
  26.  
  27. Each issue of the digest contains one or more sets of articles (called
  28. threads), with each set corresponding to a 'discussion' of a particular
  29. subject.  The articles are not edited; all articles included in this digest
  30. are in their original posted form (as received by our news server at
  31. cs.uoregon.edu).  Article threads are not added to the digest until the last
  32. article added to the thread is at least one month old (this is to ensure that
  33. the thread is dead before adding it to the digest).  Article threads that
  34. consist of only one message are generally not included in the digest.
  35.  
  36. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  37. [128.223.8.8] in the directory /pub/mac/csmp-digest.  Be sure to read the
  38. file /pub/mac/csmp-digest/README before downloading any files.  The most
  39. recent issues are available from sumex-aim.stanford.edu [36.44.0.6] in the
  40. directory /info-mac/digest/csmp.  If you don't have ftp capability, the sumex
  41. archive has a mail server; send a message with the text '$MACarch help' (no
  42. quotes) to LISTSERV@ricevm1.rice.edu for more information.
  43.  
  44. The digest is also available via email.  Just send a note saying that you
  45. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  46. automatically receive each new issue as it is created.  Sorry, back issues
  47. are not available through the mailing list.
  48.  
  49. Send administrative mail to mkelly@cs.uoregon.edu.
  50.  
  51.  
  52. -------------------------------------------------------
  53.  
  54. From: stack@techbook.com (Bill Stackhouse)
  55. Subject: Beyond List Manager
  56. Date: 4 Aug 92 23:48:25 GMT
  57. Organization: StoneTablet Publishing
  58.  
  59. The following is a press release describing a Think C library for
  60. programming lists with multiple variable columns/rows etc. that this
  61. group may find of interest. 
  62.  
  63. Bill
  64.  
  65. - -------------
  66. Portland, OR -- June 17, 1992 -- StoneTablet Publishing today
  67. introduced  StoneTable(TM) 1.0, a replacement for the Macintosh List
  68. Manager.
  69.  
  70. Available in two versions - StoneTable and StoneTable-Limited,
  71. StoneTable provides a rich set of functions for the Macintosh developer
  72. who needs to display or accept data in a tabular form.
  73. StoneTable-Limited addresses the needs of the individual developer who
  74. may be developing personal software or shareware and has a limited
  75. budget while StoneTable addressed the needs of the professional
  76. developer. Programs written for use with StoneTable-Limited do not have
  77. to be changed to use StoneTable. Conversion from the List Manager is
  78. straight forward because StoneTable contains functions with similar
  79. names and parameters that are semantically equivalent. 
  80.  
  81. Functionality includes (* indicate features only in StoneTable):
  82. - - variable width columns
  83. - - variable height rows
  84. - - data in a cell can be edited in place
  85. - - no internal limit to the amount of data that can be stored in a cell.
  86.     The amount of text displayed in a single cell is only limited by 
  87.     TextEdit.
  88. - - multiple cells can be set at once
  89. - - mouse down handling provides an optional interface for moving, 
  90.     copying, selecting, resizing a column or row plus scrolling and 
  91.     editing a cell
  92. - - columns and rows can be hidden
  93. - - optional lines between columns and/or rows
  94. - - irregular selections can be made
  95. - - columns and rows can have default titles (letters, numbers, or blank)
  96. - - ability to scroll individual cells
  97. - - columns can have applications supplied titles
  98. - - *optional lines between columns and/or rows can have a user supplied 
  99.     pattern
  100. - - *the formatting (font, size, style, first line visible) of cells can 
  101.     vary from cell to cell
  102. - - *columns and rows can have application supplied titles
  103. - - *ability to define a new drawing module.
  104. - - *optional icon palette to aid in setting table mode for extended 
  105.     selections, cell edits, etc. Useful for users that limited use of
  106.     hands and new users.
  107. - - *define height of column title border and width of row title border
  108. - - *sort columns and rows
  109. - - *edit titles in place
  110. - - *have the cursor automatically change to the proper appearance as 
  111.     it moves around the table.
  112.  
  113. System requirements:
  114. - - System 6 or latter
  115. - - Think C v5 (Does not use or require TCL)
  116. - - StoneTable 40K, StoneTable-Limited 30K (approximate code size 
  117.     in program)
  118.  
  119. The package contains:
  120. - - Think C library
  121. - - bound Programmers Guide containing approximately 60 pages
  122. - - sample program with source.
  123.  
  124. Pricing and ordering questions may directed to:
  125.     StoneTablet Publishing
  126.     Internet: stack@techbook.com
  127.     Compuserve: 70303,2546
  128.  
  129. - -- 
  130. stack@techbook.COM  Public Access User --- Not affiliated with TECHbooks
  131. Public Access UNIX and Internet at (503) 644-8135 (1200/2400, N81)
  132.  
  133. ---------------------------
  134.  
  135. From: jstevens@crick.ssctr.bcm.tmc.edu (Jason Philip Stevens)
  136. Subject: SUMMARY:  Making an icon (was "ARGH! No icon!")
  137. Date: 10 Aug 92 22:49:47 GMT
  138. Organization: Baylor College of Medicine, Houston, Tx
  139.  
  140.  
  141. To all who replied to my problem, thanks.  Evidently I had a corrupted 
  142. resource;  when I deleted my resource file and rebuilt it from scratch,
  143. all worked well.
  144.  
  145. For those who have had problems with making icons work, here are a few
  146. tips to remember:
  147.  
  148. 1) Using ResEdit 2.1 or better will be of great assistance.  Add a resource
  149. of type 'BNDL' and it will automatically add the other needed resources.
  150. (Thanks to Kenneth Anderson)
  151.  
  152. 2) Remember to set the "Bundle Bit".  You can use ResEdit to Get Info about
  153. the application and check it.  Note that some development environments will
  154. set this for you automatically (THINK C) or give you the option to (MPW, or
  155. so I am told).  (From countless submissions)
  156.  
  157. 3) Make sure that the 'Creator' and 'Signature' are the same.  The signature
  158. is set in the BNDL resource.  (From Ville Lavonius)
  159.  
  160. 4) Here is a tip that I didn't understand, but may be applicable:
  161.  
  162. "Your application needs to have a valid unique ID. That is the same as the
  163. owner resource.  If you are running system lower than 7 you could see all
  164. owner resources in the desktop file (which you could view by resedit}.
  165. Under system 7 it is similar but I don't know of any utilities that will
  166. let me browse the desk top data base..."  (This from Terje Finstad)
  167.  
  168. 5) A great tip that I received many times:
  169.  
  170. " ...one quick step you might try that worked for me once when
  171. I couldn't get the damned icon to show up is take a newly formatted floppy,
  172. i.e. you have put nothing at all on it since you formatted it; copy the
  173. application in question to the floppy and then rebuild the desktop on the
  174. floppy.  If the icon then shows up there, it will stay with the application
  175. when you copy it to your hard disk."
  176.  
  177. 6) From the same author (James Preston):
  178.  
  179. "...if you have the Norton Utilities, run that on a
  180. disk containing the application.  If there is something wrong with the way
  181. you set the bundle stuff, Norton will find it and fix it.  I've had a number
  182. of shareware apps that showed up with the generic icon until Norton fixed
  183. them."
  184.  
  185. 7) He was also the only one to point out that there is a detailed guide in
  186. Inside Macintosh VI, Chapter 9.
  187.  
  188. Finally, one last point.  One responder began his email with the following:
  189.  
  190. "This question comes up again and again, naturally.  Then a lot of people
  191. takes time-sometimes much time-to help the guy out on his particular
  192. problem- then what is the reply?  -"Now I have got it working."  Not
  193. anything on how he got it working, nothing about the options that applies
  194. to the different development environments, nothing about which system -
  195. absolutely no feedback, so why should anyone then bother answering?"
  196.  
  197. In many cases, I think questions are specific enough that it would be a waste
  198. of bandwidth to tell the whole world about a site-specific problem.  On the
  199. other hand, if you have a problem that could be of general interest, please
  200. summarize and repost.  It will save you and countless others from having to 
  201. help someone else with the same problem next week...
  202.  
  203. - -jps
  204.  
  205.  
  206. - -- 
  207. Jason Stevens            Internet:  jstevens@bcm.tmc.edu
  208. Network User Services        Voice:  (713) 798-7370
  209. Baylor College of Medicine    Opinions expressed are mine alone.
  210.  
  211. ---------------------------
  212.  
  213. From: jonh@pogo.wv.tek.com (Jon Howell)
  214. Subject: Think C Debugger & Class dynamic typing... summary
  215. Date: 14 Aug 92 17:16:38 GMT
  216. Organization: Tektronix
  217.  
  218. [summary]
  219. In article <jonh-130892150657@jonh.wv.tek.com>, jonh@pogo (that's me!)
  220. asked:
  221. > When you look
  222. > at a CObject in the Data window of the debugger, and dereference it to open
  223. > up a view of the object's structure, it views the object as though it were
  224. > the type it's declared as in the context. Why can't/doesn't it use the type
  225. > the object *really* is?  For example:
  226. > {
  227. >    CView *hokey;
  228. >    hokey = new CWindow;
  229. >    hokey ->IWindow(blah blah blah);
  230. > <> hokey ->Update();
  231. > }
  232. [I forgot to cast hokey above to make the method lookups work. I need a
  233.  newsreader with a built-in precompiler. :v]
  234. I also knew I could examine hokey in the debugger as a CWindow with:
  235.        *(CWindow *) hokey
  236. However, I really wish the debugger could do that on its own.
  237. Per Mildner <Per.Mildner@csd.uu.se> points out that
  238.  
  239. PM>There is a macro you can use in the debugger that tells you the class
  240. PM>name of an object as a string. I don't remember the name but it starts
  241. PM>with two (or possibly one) underscore. It's in the documentation
  242. PM>somewhere.
  243.  
  244. This would come in handy when you don't know just what hokey is at the
  245. moment, so you could look it up to do the cast.
  246.  
  247. > Another question: TC provides member() and class_name() (and another I
  248. > forget) functions for figuring out the dynamic type of an object. I'd
  249. > like to be able to see if an object I've been passed is of a certain
  250. > type. However, I don't want to do a string compare (class_name), and
  251. > member() seems to only tell me if the object is a member of class X or
  252. > one of its ancestors.  Is there a way I can get an integer which
  253. > uniquely identifies the class? (It'd be extra cool if it gave some info on
  254. > the hierarchy, but... :v)
  255. To which markw@wc.novell.COM (Mark Wittenberg) responded to in the best
  256. way -- with code! I'll include his message with a minimum of butchering
  257. here. Thanks to you two and d88-jwa@nada.kth.se for the replies.
  258.  
  259. - ----- snip here -----
  260. OK, there is a way.  Here are class.h and class.c that do that and more.
  261. GetClassID does what you want, and there are several other very useful
  262. routines as well.  You can just use Think's "__class" call directly if
  263. that's really all that you want (I indicate "not a class" with an id
  264. of -1 rather than Think's 0).
  265.  
  266. Note that MapClassNameToID is code largely ripped from oops.c, and this
  267. code uses unsupported and undocumented features of v5.0.2 (translation:
  268. I carefully studied oops.h and dug through memory a lot); I've been using
  269. it a long and it's been very solid for me, but caveat emptor.
  270.  
  271. NewObjectByClassId is particularly nice because it's noticeably faster
  272. than new_by_name.
  273.  
  274. /markw
  275.  
  276. - ---------------- class.h ----------------------
  277. /*
  278.  * Class.h
  279.  *      - Class ID declarations
  280.  *
  281.  * Copyright 1991 Mark Wittenberg
  282.  */
  283.  
  284. #pragma once
  285.  
  286. #include <CObject.h>
  287.  
  288. #define kNilClass       (-1)
  289.  
  290. typedef Str255  MAName;
  291. typedef int             ObjClassID;
  292.  
  293. ObjClassID      GetClassID(CObject *theObject);
  294. void            GetClassName(CObject *obj, MAName theName);
  295. void            GetClassNameFromID(ObjClassID id, MAName theName);
  296. ObjClassID      GetClassIDFromName(const MAName theName);
  297. ObjClassID      MapClassNameToID(const MAName theName);
  298. void            *NewObjectByClassId(ObjClassID currentID);
  299.  
  300. - ---------------- class.c ----------------------
  301. /*
  302.  * Class.c
  303.  *      - Class ID routines
  304.  *
  305.  * Copyright 1991 Mark Wittenberg
  306.  */
  307.  
  308. #define OOPS_PRIVATE
  309. #include "Oops.h"               // change case so that <TCL Headers>
  310. doesn't mess us up
  311. #define INDIRECT
  312. #ifdef INDIRECT
  313.         #define __new __new_indirect
  314. #else
  315.         #define __new __new_direct
  316. #endif
  317.  
  318. extern void *__new(...);
  319.  
  320. #if __option(far_code) || __option(far_data)
  321.         ERROR - We assume 2-byte IDs!
  322. #endif
  323.  
  324. #include "Class.h"
  325.  
  326. /*
  327.  * GetClassID
  328.  *      - Return the class id of an object.
  329.  */
  330. ObjClassID
  331. GetClassID(CObject *obj)
  332. {
  333.         ObjClassID      id;
  334.         
  335.         id = (ObjClassID) __class(obj);
  336.         return (id == 0) ? kNilClass : id;
  337. } /* GetClassID */
  338.  
  339. /*
  340.  * GetClassName
  341.  */
  342. void
  343. GetClassName(CObject *obj, MAName theName)
  344. {
  345.         unsigned char   *name;
  346.         
  347.         theName[0] = '\0';
  348.         name = (unsigned char *) class_name(obj);
  349.         if( name )
  350.                 BlockMove( name, theName, name[0] + 1 );
  351. } /* GetClassName */
  352.  
  353. /*
  354.  * GetClassNameFromID
  355.  */
  356. void
  357. GetClassNameFromID(ObjClassID id, MAName theName)
  358. {
  359.         unsigned char   *name;
  360.                 
  361.         theName[0] = '\0';
  362.         name = (unsigned char *) __class_name(id);
  363.         if( name )
  364.                 BlockMove( name, theName, name[0] + 1 );
  365. } /* GetClassNameFromID */
  366.  
  367. /*
  368.  * GetClassIDFromName
  369.  */
  370. ObjClassID
  371. GetClassIDFromName(const MAName theName)
  372. {
  373.         ObjClassID      id;
  374.         
  375.         id = MapClassNameToID( theName );
  376.         return (id == 0) ? kNilClass : id;
  377. } /* GetClassIDFromName */
  378.  
  379. /*
  380.  * MapClassNameToID
  381.  */
  382. ObjClassID
  383. MapClassNameToID(const MAName theName)
  384. {
  385.         struct { void *min, *max; } range;
  386.         register void *p, *q;
  387.  
  388.         asm {
  389.  
  390. ;;
  391. ;
  392. ;  establish search range
  393. ;
  394. ;;
  395.  
  396. #if __option(a4_globals)
  397.                 movea.l a4,a0
  398.                 _RecoverHandle
  399.                 _GetHandleSize
  400.                 move.l  a4,range.min
  401.                 add.l   a4,d0
  402.                 move.l  d0,range.max
  403. #else
  404.                 move.l  CurStackBase,range.min
  405.                 move.l  a5,range.max
  406. #endif
  407.  
  408. ;;
  409. ;
  410. ;  search data area for matching name (this could probably be improved)
  411. ;
  412. ;;
  413.  
  414.                 movea.l range.min,p
  415.                 movea.l theName,q
  416.                 move.w  (q)+,d1                                 ;  D1.W =
  417. 1st two bytes of name
  418. @1              cmp.w   (p)+,d1
  419.                 beq.s   @2
  420.                 cmpa.l  range.max,p
  421.                 blo.s   @1
  422. ;
  423.                 moveq   #0,d0                                   ;  search
  424. failed
  425.                 return
  426. ;
  427. @2              movea.l p,a0
  428.                 movea.l q,a1
  429.                 bra.s   @4
  430. @3              cmpm.b  (a0)+,(a1)+
  431.                 bne.s   @1                                              ; 
  432. name not found - keep looking
  433. @4              tst.b   -1(a1)
  434.                 bne.s   @3
  435.  
  436. ;;
  437. ;
  438. ;  verify we've found a class info record
  439. ;
  440. ;;
  441.  
  442.                 moveq   #~1,d0
  443.                 and.w   -4(p),d0
  444.                 lea             -4(p,d0.w),a0                   ;  A0 ==>
  445. dispatch table
  446.                 cmpa.l  range.min,a0
  447.                 blo.s   @1                                              ; 
  448. out of range - try again
  449.                 cmpa.l  range.max,a0
  450.                 bhs.s   @1                                              ; 
  451. out of range - try again
  452. ;
  453.                 moveq   #1,d0
  454.                 add.w   (a0),d0
  455.                 lsl.w   #DSHIFT,d0
  456.                 lea             ClassInfo_(name[2])+2(a0,d0.w),a1
  457.                 cmpa.l  p,a1
  458.                 bne.s   @1                                              ; 
  459. sanity check failed - try again
  460.  
  461. ;;
  462. ;
  463. ; now a0 points to the dispatch table
  464. ;
  465. ;;
  466.                 move.l  a0,d0
  467.         #ifdef BASE_REG
  468.                 sub.l   BASE_REG,d0
  469.         #endif
  470.                 return
  471.         }
  472. } /* MapClassNameToID */
  473.  
  474. /*
  475.  * NewObjectByClassId
  476.  */
  477. void *
  478. NewObjectByClassId(ObjClassID id)
  479. {
  480.         void    *cptr;
  481.         
  482.         asm {
  483.                 move.w  id,d0
  484.                 ext.l   d0
  485.         #ifdef BASE_REG
  486.                 add.l   BASE_REG,d0
  487.         #endif
  488.                 move.l  d0,cptr
  489.         }
  490.         return __new( cptr );
  491. } /* NewObjectByClassId */
  492. - -- 
  493.  
  494. - -----------------------------------------------------------------------------
  495. jonh@pogo.wv.tek.com     Jon Howell
  496.  
  497. ---------------------------
  498.  
  499. From: knop@dutecag.et.tudelft.nl (Peter Knoppers)
  500. Subject: List of bizarre, useful keyboard combinations, version 1.1
  501. Organization: Delft University of Technology, Dept. of Electrical Engineering
  502. Date: Mon, 24 Aug 1992 18:32:23 GMT
  503.  
  504. I got quite a few reactions on my posting of August 6 and I have made a few
  505. extensions and corrections.
  506.  
  507. List of bizarre, useful keyboard combinations, version 1.1, August 24, 1992.
  508. - -----------------------------------------------------------------------------
  509. Effect:        Rebuild the desktop file.
  510. How to obtain:    Hold COMMAND+OPTION during startup.
  511. Restrictions:    None.
  512. Why use this:    When your icons are suddenly lost, to reduce the size of the
  513.         desktop file (and probably in some other cases).
  514. Learned from:    Comp.sys.mac.faq, July 22, 1992.
  515. - -----------------------------------------------------------------------------
  516. Effect:        Don't mount the internal SCSI disk (ID=0) on startup.
  517. How to obtain:    Hold OPTION+COMMAND+SHIFT+BACKSPACE during startup.
  518. Restrictions:    Only on ADB keyboard.
  519. Why use this:    To by-pass (not boot from) a corrupt internal hard disk.
  520. Learned from:    Posting by Daniel Mueller <muller_d@elgc.epfl.ch>.
  521. - -----------------------------------------------------------------------------
  522. Effect:        Startup with a minimal ROM-disk containing System 6.0.3,
  523.         Finder 6.1x and AppleShare.
  524. How to obtain:    Hold COMMAND+OPTION+X+O during startup.
  525. Restrictions:    Only on the Mac Classic; this version of the System is NOT
  526.         recommended to run the Classic under.
  527. Why use this;    Don't know.
  528. Learned from:    The Macintosh secret trick list, 16 April, 1992.
  529. - -----------------------------------------------------------------------------
  530. Effect:        Zap the PRAM (Parameter RAM).
  531. How to obtain:    Hold COMMAND+OPTION+P+R during startup.
  532. Restrictions:    Only on System 7 and your timing seems to be critical...
  533. Why use this:    This sometimes cures weird crashes.
  534. Learned from:    The Macintosh secret trick list, 16 April, 1992.
  535. - -----------------------------------------------------------------------------
  536. Effect:        Eject floppy disk before looking for a boot disk.
  537. How to obtain:    Hold MOUSEBUTTON during startup.
  538. Restrictions:    None.
  539. Why use this:    If you have a boot disk in the floppy drive, but don't want
  540.         to boot from it.
  541. Learned from:    Michael Grabenstein <grabenst@umbc3.umbc.edu>
  542.         or <ZMEG@AACC.bitnet>.
  543. - -----------------------------------------------------------------------------
  544. Effect:        Kill the current foreground process.
  545. How to obtain:    Type COMMAND+OPTION+ESCAPE.
  546. Restrictions:    Only on System 7.0.
  547. Why use this:    After an application has crashed this might regain you
  548.         control of the machine in order to save work done in other
  549.         applications before restarting. Restart as soon as possible
  550.         afterwards because some things may have been clobbered by
  551.         the crashed application.
  552. Learned from:    The Macintosh secret trick list, 16 April, 1992.
  553. - -----------------------------------------------------------------------------
  554. Effect:        Reset.
  555. How to obtain:    Type COMMAND+CONTROL+POWER
  556.         (power is the key with the triangle on it).
  557. Restrictions:    Macintosh LC or Macintosh IIsi (which don't have a restart
  558.         button).
  559. Why use this:    To restart a hung system.
  560. Learned from:    The Macintosh secret trick list, 16 April, 1992.
  561. - -----------------------------------------------------------------------------
  562. Effect:        Restart the Mac.
  563. How To Obtain:    Type COMMAND-SHIFT-POWER.
  564.         (power is the key with the triangle on it).
  565. Restrictions:    Must have programmer's key installed.
  566. Why use this:    To restart a hung system.
  567. Learned from:    Joshua Rabinowitz <joshr@ptolemy.arc.nasa.gov>.
  568. - -----------------------------------------------------------------------------
  569. Effect:        Interrupt; enter the debugger.
  570. How to obtain:    Type COMMAND+POWER.
  571.         (power is the key with the triangle on it).
  572. Restrictions:    Macintosh LC or Macintosh IIsi (which don't have an interrupt
  573.         button).
  574. Why use this:    Enter the debugger (if installed, else crashes the computer).
  575. Learned from:    The Macintosh secret trick list, 16 April, 1992.
  576. - -----------------------------------------------------------------------------
  577. Please MAIL additions/corrections/suggestions to knop@duteca.et.tudelft.nl
  578.  
  579. If there is interest, I will maintain, correct and extend this list. I expect
  580. that the "Restrictions:" lines are not 100% correct...
  581.  
  582. I am interested in suggestions on a sorting order for these combinations. The
  583. current order is: first all combinations that can be used during the boot
  584. phase, then the combinations that can be used during normal operations.
  585. Within each group the order is more or less arbitrary/accidental.
  586. For instance: should I place COMMAND+CONTROL+POWER before or after COMMAND+
  587. SHIFT+POWER etc. ?
  588.  
  589. - --Peter Knopprs - knop@duteca.et.tudelft.nl
  590.  
  591. ---------------------------
  592.  
  593. From: hugues@isoftfr.isoft.fr (Hugues Marty)
  594. Subject: UNofficial description of 2 Layer Manager calls
  595. Date: 28 Aug 92 08:11:24 GMT
  596.  
  597.  
  598.  
  599. This post contains a header and an example of how to use some calls of
  600. the UNDOCUMENTED (as long as I know) Layer Manager which comes along
  601. with System 7.  Of course, this is NOT an official document, and is
  602. here for information only. I don't have News access at the moment (I'm
  603. sending this via e-mail), so please send mail me copies if you post
  604. follow-ups.
  605.  
  606. PS: it only describes 2 calls of the LayerDispatch trap (0xA829).
  607. PPS: seems to work under 7.1 beta.
  608.  
  609. - ---- C #include file following
  610.  
  611. /* Layers.h */
  612.  
  613. /* Part of the undocumented Layer Manager structures and calls
  614.  * Information found with the help of MacsBug under MacOS 7.0.
  615.  * Please note that using this information may make your mac
  616.  * explode (hey, this could be a subject for a QuickTime moovie !);
  617.  * so use at your own risks, this may break in the future,
  618.  * etc.. (usual disclaimeer).
  619.  * I only wish that Apple will document this manager in a very near
  620.  * future (let's dream...).
  621.  *
  622.  * What I found was that a layer is associated with each running
  623.  * applications (if it has a user-interface), which groups all
  624.  * windows of that application. This is how you can hide an application
  625.  * (remember 'applications' menu under system 7) and get the list of
  626.  * other applications windows. Have fun.
  627.  *
  628.  * PS : If you have more information on the Layer Manager, please
  629.  * let me know! You can join me at hugues@isoft.fr
  630.  */
  631.  
  632. #include <PasStrs.h>
  633.  
  634. // LayerRecord is similar to a WindowRecord.
  635. typedef WindowRecord LayerRecord;
  636. typedef WindowPeek LayerPtr;
  637.  
  638. // This records some information on the process which owns
  639. // the layer... Most of it is not clear (there are pointers
  640. // to other LayerRecords, to a heap zone, etc. in the unknown
  641. // parts)
  642. typedef struct {
  643.    long    unknown1;
  644.    OSType    signature;           // The process sig.
  645.    OSType    creator;             // The process creator
  646.    char      unknown2[24];
  647.    ProcessSerialNumber layerPSN;  // The process PSN
  648.    char      unknown3[40];
  649.    Handle    moreLayerInfo;       // This handle is 212 bytes sized.
  650. } LayerInfo, *LayerInfoPtr;
  651.  
  652. // This function returns a pointer to the first layer record
  653. // of the front layer on screen (front application).
  654. // Other ones are then accessed by the GetNextLayer macro.
  655. pascal LayerPtr GetFirstLayer(void)
  656.     = {0x7003, 0xA829};
  657.  
  658. // This function returns a pointer to the first window record
  659. // in the windows list of this layer.
  660. pascal WindowPtr GetFirstLayerWindow(LayerPtr aLayer)
  661.     = {0x7006, 0xa829};
  662.  
  663. // Some macros to access other information, and to hide and show a layer
  664. #define GetNextLayer(aLayer) (aLayer->nextWindow)
  665. #define GetLayerInfo(aLayer) ((LayerInfoPtr)aLayer->refCon)
  666. #define HideLayer(aLayer) HideWindow((WindowPtr)aLayer)
  667. #define ShowLayer(aLayer) ShowWindow((WindowPtr)aLayer)
  668. #define ShowHideLayer(aLayer,showFlag) ShowHide((WindowPtr)aLayer, showFlag)
  669. #define HiddenLayer(aLayer) aLayer->visible
  670.  
  671. // GetLayerName will return an address in a handle. Be aware of that.
  672. #define GetLayerName(aLayer) \
  673. (unsigned char *) ( (*GetLayerInfo(aLayer)->moreLayerInfo) + 0x38)
  674.  
  675.  
  676. /** Some sample code to show how to put the list of layers and their
  677.  ** windows names in a styled text with TextEdit.
  678.  **
  679.  
  680.   TEHandle hTE;
  681.   LayerPtr theLayer;
  682.   Str255 name;
  683.   TextStyle style;
  684.   WindowPeek window;
  685.   LayerInfoPtr info;
  686.     
  687.   hTE = TEStylNew(&windowRect, &windowRect);
  688.   theLayer = GetFirstLayer();
  689.   do {
  690.     style.tsFace = bold;
  691.     TESetStyle(doFace, &style, false, hTE);
  692.     Pstrcpy(name, GetLayerName(theLayer));
  693.     TEInsert(name+1, name[0], hTE);
  694.     TEInsert("\015", 1, hTE);
  695.     style.tsFace = 0;
  696.     TESetStyle(doFace, &style, false, hTE);
  697.     window = (WindowPeek) GetFirstLayerWindow(theLayer);
  698.     while(window) {
  699.       if (StripAddress(window->titleHandle) && StripAddress(*window->titleHandle)) {
  700.         Pstrcpy(name, *window->titleHandle);
  701.     TEInsert(name+1, name[0], hTE);
  702.     TEInsert("\015", 1, hTE);
  703.       }
  704.       window = window->nextWindow;
  705.     }
  706.   } while (theLayer = GetNextLayer(theLayer));
  707.  
  708. **  The End */
  709. - --
  710. Hugues MARTY - ISoft, Chemin de Moulon, F-91190 Gif-sur-Yvette FRANCE
  711. e-mail: hugues@isoft.fr
  712.  
  713. ---------------------------
  714.  
  715. From: berns@cwi.nl (Marc Berns)
  716. Subject: How to query current pixel depth?
  717. Date: 12 Jul 92 14:50:28 GMT
  718.  
  719. I'm a baby mac programmer with a (likely stupid) question.  Be gentle with me.
  720.  
  721. I'd like to decide whether to display a color or b&w PICT.  I do know how
  722. (via gestalt) to check for ColorQD, but I do *not* know how to check the
  723. pixel depth.  I can display a color PICT on a PowerBook, for example, but
  724. it looks like s**t.  So...
  725.  
  726. What is the "right" way to ask for the pixel depth?
  727.  
  728. Thanks for any wisdom you might have for me...
  729.  
  730. - --dave jacobs (squatting on Marc Berns' account)
  731.  
  732. +++++++++++++++++++++++++++
  733.  
  734. From: peirce@outpost.SF-Bay.org (Michael Peirce)
  735. Date: 12 Jul 92 18:53:41 GMT
  736. Organization: Peirce Software
  737.  
  738.  
  739. In article <6653@charon.cwi.nl> (comp.sys.mac.programmer), berns@cwi.nl (Marc Berns) writes:
  740. > I'm a baby mac programmer with a (likely stupid) question.  Be gentle with me.
  741. > I'd like to decide whether to display a color or b&w PICT.  I do know how
  742. > (via gestalt) to check for ColorQD, but I do *not* know how to check the
  743. > pixel depth.  I can display a color PICT on a PowerBook, for example, but
  744. > it looks like s**t.  So...
  745. > What is the "right" way to ask for the pixel depth?
  746.  
  747. The best way to do this is by using DeviceLoop().  You pass this trap
  748. a region you want redrawn and a drawing procedure.  It calls your
  749. procedure repeatedly telling which bit depth your drawing to.  
  750.  
  751. This has the benefit of working when you have a window that spans
  752. monitors and each of those monitors is a different bit depth.
  753.  
  754. - --  Michael Peirce      --   peirce@outpost.SF-Bay.org
  755. - --  Peirce Software     --   Suite 301, 719 Hibiscus Place
  756. - --                      --   San Jose, California USA 95117
  757. - --  Makers of...        --   voice: (408) 244-6554 fax: (408) 244-6882
  758. - --            SMOOTHIE  --   AppleLink: peirce & America Online: AFC Peirce
  759.  
  760. +++++++++++++++++++++++++++
  761.  
  762. From: zobkiw@world.std.com (Joe Zobkiw)
  763. Organization: The World Public Access UNIX, Brookline, MA
  764. Date: Sun, 12 Jul 1992 23:33:31 GMT
  765.  
  766. There is a lo-mem global called ChunkyDepth that is a word. This is the current
  767. depth of the main device. In MacsBug type "dw ChunkyDepth" for an example.
  768.  
  769. It is documented in a header file so I'm not sure if that makes it legal or
  770. not. I'm also not sure how reliable it is but it seems to be right everytime
  771. I've checked it.
  772.  
  773.  
  774. - -- 
  775. - -------------------------------------------------------------
  776. joe zobkiw         zobkiw@world.std.com        aol: aflzobkiw
  777.  
  778.  
  779. +++++++++++++++++++++++++++
  780.  
  781. From: joseph@joebloe.maple-shade.nj.us (Joseph Nathan Hall)
  782. Date: Mon, 13 Jul 92 20:41:17 EDT
  783. Organization: 5 Sigma Software
  784.  
  785.  
  786. In article <6653@charon.cwi.nl> (berns@cwi.nl), you write:
  787. ) I'd like to decide whether to display a color or b&w PICT.  I do know how
  788. ) (via gestalt) to check for ColorQD, but I do *not* know how to check the
  789. ) pixel depth. ...
  790. ) What is the "right" way to ask for the pixel depth?
  791.  
  792. What about checking the pixelSize of the window manager port?
  793. GetCWMgrPort, etc.  Having only one monitor, I don't know what troubles
  794. this approach has with multiple monitors of different depth...
  795.  
  796. uunet!joebloe!joseph   (609) 273-8200 day   joseph%joebloe@uunet.uu.net
  797. v   v  sssss | Certified Guru: all-grain brewing,| 2102 Ryan's Run East
  798.  v v  s   s  | C, synthesizer comp & arranging,  | Rt 38 & 41
  799.   v    sss   | photography. Also not a bad cook. | Maple Shade NJ 08052
  800. - -----My employer isn't paying for this, and my opinions are my own-----
  801.  
  802. +++++++++++++++++++++++++++
  803.  
  804. From: Sherman@128.147.155.27 (Sherman Uitzetter)
  805. Date: 16 Jul 92 18:05:19 GMT
  806. Organization: Pittsburgh NMRI
  807.  
  808. In article <01050166.8f6nde@joebloe.maple-shade.nj.us> Joseph Nathan
  809. Hall, joseph@joebloe.maple-shade.nj.us writes:
  810. >) What is the "right" way to ask for the pixel depth?
  811. >
  812. >What about checking the pixelSize of the window manager port?
  813. >GetCWMgrPort, etc.  Having only one monitor, I don't know what troubles
  814. >this approach has with multiple monitors of different depth...
  815.  
  816.  
  817.   How about checking the pixelSize of the port you're going to draw
  818. into?  Just before the DrawPicture() call, check
  819.           (**(((CGrafPtr) thePort)->portPixMap)).pixelSize
  820. this assumes that the current port is a CGrafPort (this should
  821. probably be checked.)
  822.  
  823.  
  824. - -Sherman.
  825.  
  826. +++++++++++++++++++++++++++
  827.  
  828. From: keith@taligent.com (Keith Rollin)
  829. Date: 16 Jul 92 20:39:43 GMT
  830. Organization: Taligent
  831.  
  832. In article <15694@pitt.UUCP>, Sherman@128.147.155.27 (Sherman Uitzetter) writes:
  833. > In article <01050166.8f6nde@joebloe.maple-shade.nj.us> Joseph Nathan
  834. > Hall, joseph@joebloe.maple-shade.nj.us writes:
  835. > >) What is the "right" way to ask for the pixel depth?
  836. > >
  837. > >What about checking the pixelSize of the window manager port?
  838. > >GetCWMgrPort, etc.  Having only one monitor, I don't know what troubles
  839. > >this approach has with multiple monitors of different depth...
  840. >   How about checking the pixelSize of the port you're going to draw
  841. > into?  Just before the DrawPicture() call, check
  842. >           (**(((CGrafPtr) thePort)->portPixMap)).pixelSize
  843. > this assumes that the current port is a CGrafPort (this should
  844. > probably be checked.)
  845.  
  846. I don't think this will work. According to Forrest The Awesome in develop #10,
  847. the pixMap of a color window will always point to the pixMap corresponding to
  848. the main device, even if the window is entirely on another monitor.
  849.  
  850. The thing to do is find out what device the window is on (see Technote #79 or
  851. DTS sample code for a sample of a routine that will do this). Then check the
  852. pixelSize field of the pixMap for that device.
  853.  
  854. - --
  855. Keith Rollin
  856. Phantom Programmer
  857. Taligent, Inc.
  858.  
  859.  
  860. ---------------------------
  861.  
  862. From: S4161006@deimos.ucc.umass.edu (S4161006)
  863. Subject: Think C arrays
  864. Organization: University of Massachusetts at Amherst
  865. Date: Thu, 16 Jul 1992 19:43:50 GMT
  866.  
  867.  
  868. I want to use Think C to handle arrays of floating point numbers.  The arrays
  869. must have a size of on the order of 8192 rows by 16 columns.  The Think C
  870. guide says that arrays have to be less than 32K!!!  Can someone provide a 
  871. solution to this problem.  I am new to C programming on the Mac (previously
  872. using Fortran and QuickBasic) and woudl appreciate any information.  Thanks
  873. in advance.
  874.  
  875. Mark Normand
  876.  
  877.  
  878. +++++++++++++++++++++++++++
  879.  
  880. From: zobkiw@world.std.com (Joe Zobkiw)
  881. Organization: The World Public Access UNIX, Brookline, MA
  882. Date: Fri, 17 Jul 1992 13:14:00 GMT
  883.  
  884. You want a multiple dimensioned array, easy :)
  885.  
  886. There is no need to allocate a zillion pointers like many programmers will
  887. tell you to do!
  888.  
  889. Allocate _one_ Pointer the size of the array. Then, you simply use a
  890. #define macro to access it's items. For instance, a two dimensional
  891. array and macro might look like this:
  892.  
  893. typedef struct {
  894.     char    direction;
  895.     char    flags;
  896. } PointList, *PointListPtr;
  897.  
  898. #define ARRAY_ITEM(x, y, width, arrayP) (arrayP[(y*width)+x])
  899.  
  900. To access elements you might say:
  901.  
  902. PointList pl = ARRAY_ITEM(x, y, sArrayWidth, sPointsArrayPtr);
  903.  
  904. or
  905.  
  906. ARRAY_ITEM(x, y, sArrayWidth, sPointsArrayPtr) = pl;
  907.  
  908. In the above examples, sPointsArrayPtr is a ptr to the array. Each element
  909. of the array is a PointList structure. sArrayWidth is the width of the
  910. array. You would allocate the array like this:
  911.  
  912. sPointsArrayPtr = (PointListPtr)NewPtrClear(sArrayWidth * sArrayHeight *
  913.           sizeof(PointList));    // allocate our ptr
  914.  
  915. Hope this helps.
  916. - -- 
  917. - -------------------------------------------------------------
  918. joe zobkiw         zobkiw@world.std.com        aol: aflzobkiw
  919.  
  920.  
  921. ---------------------------
  922.  
  923. From: rbarris@orion.oac.uci.edu (Robert C. Barris)
  924. Subject: MoveHHi invalidates heap?
  925. Date: 14 Jul 92 17:07:54 GMT
  926. Organization: University of California, Irvine
  927.  
  928. In article <1992Jul13.113950.26074@doug.cae.wisc.edu> jverdega@cae.wisc.edu (Jeffrey Verdegan) writes:
  929. >I'm using MacsBug 6.2.2 to debug an app I'm writing in Think C 5.0, and I
  930. >noticed some weird behavior.  Near the start of the program, I have a call to
  931. >Debugger().  When I enter the debugger, I type hs and athc to turn on heap
  932. >scrambling and checking.  Then, whenever my program calls MoveHHi, I get 
  933. >tossed into the debugger with the message, "The heap is invalid."  
  934. >
  935.  
  936. I've been doing a lot of this sort of thing lately. ATHC, if I remember
  937. right, checks the heap 'on entry' to a trap and not on exit (since
  938. that's impossible to catch in the general case).
  939. The heap may be bad before you get to MoveHHi.
  940.  
  941. Also... traps during VBL's get HC'd too... so if the MoveHHi is executing
  942. and a VBL or other interrupt occurs, MacsBug will try to check the heap
  943. (if any traps are executed during the VBL/int task, of course)
  944. and of course find that it's inconsistent (since MoveHHi is shuffling it
  945. at the moment). So do a SC7 and see if you are actually in the middle
  946. of the VBL handling code (it will be in the ROM, possibly a few levels up
  947. on the calling chain). Some 'heap invalid' messages can actually be ignored.
  948.  
  949. I hope this helps.
  950.  
  951. Rob Barris
  952. Quicksilver Software Inc.
  953.  
  954. +++++++++++++++++++++++++++
  955.  
  956. From: dodd@apple.com (Mike Dodd)
  957. Date: Wed, 15 Jul 1992 01:46:19 GMT
  958. Organization: Apple Computer Inc.
  959.  
  960. In article <1992Jul13.113950.26074@doug.cae.wisc.edu>, jverdega@cae.wisc.edu (Jeffrey Verdegan) writes:
  961. > I'm using MacsBug 6.2.2 to debug an app I'm writing in Think C 5.0, and I
  962. > noticed some weird behavior.  Near the start of the program, I have a call to
  963. > Debugger().  When I enter the debugger, I type hs and athc to turn on heap
  964. > scrambling and checking.  Then, whenever my program calls MoveHHi, I get 
  965. > tossed into the debugger with the message, "The heap is invalid."  
  966.  
  967. does MacsBug break at your call to MoveHHi, or _inside_ the call to MoveHHi??
  968. When the memory manager is munging the heap, it can be in a state where the heap
  969. is temporarily invalid. MacsBug will catch this, even though the Memory Manager
  970. is going to fix it up. Basically, ATHC on BlockMove and one other call (I forget
  971. which) will tend to be called during heap compaction when the heap is temporarily
  972. invalid...
  973.  
  974. - -Mike Dodd-
  975. Apple Computer
  976. ** What I say is my opinion. Not Apple's. **
  977.  
  978.  
  979. +++++++++++++++++++++++++++
  980.  
  981. From: jverdega@cae.wisc.edu (Jeffrey Verdegan)
  982. Organization: U of Wisconsin-Madison College of Engineering
  983. Date: 17 Jul 92 10:31:31 CDT
  984.  
  985. I wirte:
  986. >> I'm using MacsBug 6.2.2 to debug an app I'm writing in Think C 5.0, and I
  987. >> noticed some weird behavior.  Near the start of the program, I have a call to
  988. >> Debugger().  When I enter the debugger, I type hs and athc to turn on heap
  989. >> scrambling and checking.  Then, whenever my program calls MoveHHi, I get 
  990. >> tossed into the debugger with the message, "The heap is invalid."  
  991.  
  992. Mike Dodd replies:
  993. >
  994. >does MacsBug break at your call to MoveHHi, or _inside_ the call to MoveHHi??
  995. >When the memory manager is munging the heap, it can be in a state where the heap
  996. >is temporarily invalid. MacsBug will catch this, even though the Memory Manager
  997. >is going to fix it up. Basically, ATHC on BlockMove and one other call (I forget
  998. >which) will tend to be called during heap compaction when the heap is temporarily
  999. >invalid...
  1000. >
  1001. >** What I say is my opinion. Not Apple's. **
  1002.  
  1003. I kind of guessed (and hoped) it might be something like that, and I've gotten 
  1004. one or two other responses that suggest the same thing.  I'm not sure, but I 
  1005. think it's inside MoveHHi.  Everything else is resonably clean.  I know this
  1006. because I took all the calls to MoveHHi out, and ran the program for a while
  1007. with no problems, so I suspect it's just this sort of thing.
  1008.  
  1009. Thanks everyone for your help!
  1010. Jeff
  1011.  
  1012. - ----------
  1013.  
  1014. Jeff Verdegan
  1015. University of Wisconsin-Madison
  1016. Computer-Aided Engineering Center
  1017. jjv@caestaff.engr.wisc.edu
  1018. (608) 263-1875
  1019.  
  1020.  
  1021. ---------------------------
  1022.  
  1023. Organization: Carnegie Mellon, Pittsburgh, PA
  1024. Date: Thu, 16 Jul 1992 14:58:32 -0400 
  1025. From: Brian Campbell <bc2k+@andrew.cmu.edu>
  1026. Subject: Dragging Lines
  1027.  
  1028.     I am currently writing code (in Think C) for a graphical user
  1029. interface on the Mac.  The program is for mechanical (dynamic) system
  1030. modeling (i.e., it's a circuit simulator).  I currently have the core of
  1031. the program done... the user selects a tool (mass, spring, damper, etc)
  1032. from a tool palette, plots it down in in a grid, clicks on the icon's
  1033. handles, and makes connections.
  1034.  
  1035.     I am using DragGrayRgn() to drag an icon around the screen, but I
  1036. also want to drag its connecting lines along with it (so that the MOVED
  1037. icon carries its end of the connecting lines with it while the other end
  1038. remains stationary on another icon).  In an attempt to do this, I made
  1039. the last parameter of DragGrayRgn() a pointer to a function which uses
  1040. GetMouse() to continually draw a new connecting line from the moving
  1041. icon to the stationary one while continually erasing the old lines by
  1042. changing the PenPat to white.  This of course has the side effect of
  1043. also erasing any objects that are in the paths of the lines.
  1044.     Any ideas on how to drag the line while not disturbing the objects
  1045. in its path would be greatly appreciated.
  1046.  
  1047.  
  1048.  
  1049.  
  1050. ******************************************************************************
  1051. Brian
  1052. bc2k@andrew.cmu.edu (until 8/14)
  1053. bjc2d@kelvin.seas.virginia.edu (permanent)
  1054.  
  1055. +++++++++++++++++++++++++++
  1056.  
  1057. From: lari@bach.cs.unc.edu (Humayun Lari)
  1058. Date: 17 Jul 92 03:23:49 GMT
  1059. Organization: University of North Carolina, Chapel Hill
  1060.  
  1061. In article <UeNQPM600WBNA400kT@andrew.cmu.edu> bc2k+@andrew.cmu.edu (Brian Campbell) writes:
  1062. >    I am using DragGrayRgn() to drag an icon around the screen, but I
  1063. >also want to drag its connecting lines along with it (so that the MOVED
  1064. >icon carries its end of the connecting lines with it while the other end
  1065. >remains stationary on another icon).  In an attempt to do this, I made
  1066. >the last parameter of DragGrayRgn() a pointer to a function which uses
  1067. >GetMouse() to continually draw a new connecting line from the moving
  1068. >icon to the stationary one while continually erasing the old lines by
  1069. >changing the PenPat to white.  This of course has the side effect of
  1070. >also erasing any objects that are in the paths of the lines.
  1071.  
  1072. One way to do this is to emulate the behaviour of DragGrayRgn in your line
  1073. drawing function. When you receive the mouseDown event, before you call
  1074. DragGrayRgn, draw the current connecting line with a pen pattern of gray and
  1075. a pen mode of patXor, and save the current location of the mouse. In your 
  1076. drawing function, compare the current location of the mouse with the saved
  1077. location. If it has changed, redraw the last connecting line (again, using
  1078. gray and patXor, which will erase the line) and draw the new connecting line.
  1079.  
  1080. When DragGrayRgn returns, redraw the current connecting line (which will erase
  1081. it) and draw it "for real". BTW, I think DragGrayRgn uses PinRect to keep the
  1082. region within the limiting rectangle; you should do the same with the mouse
  1083. location in your drawing function.
  1084.  
  1085. It might be smoother to just write your own dragging function, of course, since
  1086. that gives you extra control. All you really need is a Draw function that takes
  1087. a point as its parameter, and draws the icon region and the connecting lines at
  1088. that point. Then all you have to do is track the mouse and use the above
  1089. algorithm to call Draw twice whenever the mouse moves. (E-mail if this doesn't
  1090. make sense.)
  1091.  
  1092.  
  1093. Humayun Lari
  1094. (lari@cs.unc.edu)
  1095.  
  1096. ---------------------------
  1097.  
  1098. From: busey@milton.u.washington.edu (Thomas Busey)
  1099. Subject: Can copybits _add_ the source pixmap index to the dest index?
  1100. Organization: University of Washington
  1101. Date: Thu, 16 Jul 1992 21:46:53 GMT
  1102.  
  1103. For various mundane reasons, I'm trying to combine two pixmaps.  I've got the 
  1104. indicies all set up so that if I can just add the index values in the pixmap
  1105. fields together, I will have a composite image that will have the properties
  1106. I want.  My problem is that I can't get copybits to just add the two index 
  1107. values together.  ScrOr comes close, but no cigar.  As far as I can tell, the 
  1108. Arithemetic Drawing modes work on the actual rgb color, not the index value,
  1109. and this will not work for me.
  1110.  
  1111. If I absolutely have to, I can add the two values with a special routine.  
  1112. However, for compatiblility and speed reasons, I really don't want to do this. 
  1113. Has anyone had any luck in getting copybits to add two pixmap values together
  1114. (source and dest) and place the result (in the dest pixmap)?
  1115.  
  1116. For those who are interested, I'm taking two 4-bit pictures (from an apple
  1117. scanner) and combining them into one 8-bit composite.  With the appropriate
  1118. choice of cluts, I can make either picture visible, and switch between the
  1119. two pictures at 60 times a second.  I can also make both pictures invisible
  1120. and still have the images on the screen.  This is ideal for use with SEGA-
  1121. 3d glasses for displaying stereo images.  I'm planning on making the source 
  1122. code availible to the public, so your information now will be rewarded later!
  1123.  
  1124. Thanks,
  1125. Tom Busey
  1126. busey@u.washington.edu
  1127. University of Washington
  1128. Seattle, WA 98195
  1129.  
  1130. +++++++++++++++++++++++++++
  1131.  
  1132. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  1133. Organization: Kalamazoo College
  1134. Date: Fri, 17 Jul 1992 14:04:26 GMT
  1135.  
  1136. busey@milton.u.washington.edu (Thomas Busey) writes:
  1137. >I'm trying to combine two pixmaps.
  1138.  
  1139. In a quite wacky way that nothing in the toolbox supports! :-)
  1140.  
  1141. >I've got the 
  1142. >indicies all set up so that if I can just add the index values in the pixmap
  1143. >fields together, I will have a composite image that will have the properties
  1144. >I want.
  1145.  
  1146. Not quite;  I think you want to shift one index left four bits, and then
  1147. add (or 'or', it comes to the same thing).
  1148.  
  1149. >My problem is that I can't get copybits to just add the two index 
  1150. >values together.  ScrOr comes close, but no cigar.  As far as I can tell, the 
  1151. >Arithemetic Drawing modes work on the actual rgb color, not the index value,
  1152. >and this will not work for me.
  1153.  
  1154. Yes.  This is true.
  1155.  
  1156. >If I absolutely have to, I can add the two values with a special routine.  
  1157. >...for compatiblility and speed reasons, I really don't want to do this. 
  1158.  
  1159. I think you'll have to.  Compatibility isn't an issue;  as long as
  1160. you're only writing to your off-screen image, you'll be compatible.
  1161.  
  1162. >For those who are interested, I'm taking two 4-bit pictures (from an apple
  1163. >scanner) and combining them into one 8-bit composite.  With the appropriate
  1164. >choice of cluts, I can make either picture visible, and switch between the
  1165. >two pictures at 60 times a second.
  1166.  
  1167. Make a routine that combines the two 4-bit pixel images into an 8-bit
  1168. pixel image.  Call that, then CopyBits the result to the screen.
  1169.  
  1170. If you gotta have more speed than that, then you can write directly to
  1171. the screen and still stay compatible, but it takes a lot more effort.
  1172. Of course, if you only want to display still images in 3-D, this isn't a
  1173. problem;  the limiting factor is how fast the images change, not the 60
  1174. frames per second.
  1175.  
  1176. Allow me to point out that ActivatePalette() cannot be called from
  1177. within an interrupt, but that SetEntries() can.  So either (a) you do
  1178. the palette-flipping in a tight loop, and never give time to background
  1179. processes, or (b) you use the Color Manager at interrupt time, and never
  1180. share the screen with background applications.  If those 4-bit pictures
  1181. use all 16 colors, you'll need to use the Color Manager anyway, because
  1182. the Palette Manager can't change colors 0 or 255 on an 8-bit screen.
  1183. So you're not going to be Mr. Compatibility anyway;  you may as well
  1184. grit your teeth and dig in.  :-)
  1185. - -- 
  1186.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  1187.  I'm having a lot of trouble seeing how a request that you "shut up" can be
  1188.  interpreted as "looking to other people for validation."      - Tim Pierce
  1189.  
  1190. ---------------------------
  1191.  
  1192. End of C.S.M.P. Digest
  1193. **********************
  1194.